<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/* 
<span class='line'>  2</span>  * Timemap.js Copyright 2010 Nick Rabinowitz.
<span class='line'>  3</span>  * Licensed under the MIT License (see LICENSE.txt)
<span class='line'>  4</span>  */</span><span class="WHIT">
<span class='line'>  5</span> 
<span class='line'>  6</span> </span><span class="COMM">/**
<span class='line'>  7</span>  * @fileOverview
<span class='line'>  8</span>  * JSON Loaders (JSONP, JSON String)
<span class='line'>  9</span>  *
<span class='line'> 10</span>  * @author Nick Rabinowitz (www.nickrabinowitz.com)
<span class='line'> 11</span>  */</span><span class="WHIT">
<span class='line'> 12</span> </span><span class="WHIT"> 
<span class='line'> 13</span> </span><span class="COMM">// for JSLint</span><span class="WHIT">
<span class='line'> 14</span> </span><span class="COMM">/*global TimeMap */</span><span class="WHIT">
<span class='line'> 15</span> 
<span class='line'> 16</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 17</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">loaders</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMap.loaders</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 18</span> 
<span class='line'> 19</span> </span><span class="COMM">/**
<span class='line'> 20</span>  * @class
<span class='line'> 21</span>  * JSONP loader - expects a service that takes a callback function name as
<span class='line'> 22</span>  * the last URL parameter.
<span class='line'> 23</span>  *
<span class='line'> 24</span>  * &lt;p>The jsonp loader assumes that the JSON can be loaded from a url with a "?" instead of
<span class='line'> 25</span>  * the callback function name, e.g. "http://www.test.com/getsomejson.php?callback=?". See
<span class='line'> 26</span>  * &lt;a href="http://api.jquery.com/jQuery.ajax/">the jQuery.ajax documentation&lt;/a> for more
<span class='line'> 27</span>  * details on how to format the url, especially if the parameter is not called "callback".
<span class='line'> 28</span>  * This works for services like Google Spreadsheets, etc., and accepts remote URLs.&lt;/p>
<span class='line'> 29</span>  * @name TimeMap.loaders.jsonp
<span class='line'> 30</span>  * @augments TimeMap.loaders.remote
<span class='line'> 31</span>  *
<span class='line'> 32</span>  * @example
<span class='line'> 33</span> TimeMap.init({
<span class='line'> 34</span>     datasets: [
<span class='line'> 35</span>         {
<span class='line'> 36</span>             title: "JSONP Dataset",
<span class='line'> 37</span>             type: "jsonp",
<span class='line'> 38</span>             options: {
<span class='line'> 39</span>                 url: "http://www.example.com/getsomejson.php?callback=?"
<span class='line'> 40</span>             }
<span class='line'> 41</span>         }
<span class='line'> 42</span>     ],
<span class='line'> 43</span>     // etc...
<span class='line'> 44</span> });
<span class='line'> 45</span>  *
<span class='line'> 46</span>  * @constructor
<span class='line'> 47</span>  * @param {Object} options          All options for the loader:
<span class='line'> 48</span>  * @param {String} options.url          URL of JSON service to load, callback name replaced with "?"
<span class='line'> 49</span>  * @param {mixed} [options[...]]        Other options (see {@link loaders.remote})
<span class='line'> 50</span>  */</span><span class="WHIT">
<span class='line'> 51</span> </span><span class="NAME">loaders.jsonp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">loader</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">loaders.remote</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 53</span> </span><span class="WHIT">    </span><span class="WHIT">
<span class='line'> 54</span> </span><span class="WHIT">    </span><span class="COMM">// set ajax settings for loader</span><span class="WHIT">
<span class='line'> 55</span> </span><span class="WHIT">    </span><span class="NAME">loader.opts.dataType</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'jsonp'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="WHIT">    
<span class='line'> 57</span>     </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">loader</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 59</span> 
<span class='line'> 60</span> </span><span class="COMM">/**
<span class='line'> 61</span>  * @class
<span class='line'> 62</span>  * JSON string loader - expects a plain JSON array.
<span class='line'> 63</span>  *
<span class='line'> 64</span>  * &lt;p>The json_string loader assumes an array of items in plain JSON, with no
<span class='line'> 65</span>  * callback function - this will require a local URL.&lt;/p>
<span class='line'> 66</span>  * @name TimeMap.loaders.json
<span class='line'> 67</span>  * @class
<span class='line'> 68</span>  *
<span class='line'> 69</span>  * @augments TimeMap.loaders.remote
<span class='line'> 70</span>  *
<span class='line'> 71</span>  * @example
<span class='line'> 72</span> TimeMap.init({
<span class='line'> 73</span>     datasets: [
<span class='line'> 74</span>         {
<span class='line'> 75</span>             title: "JSON String Dataset",
<span class='line'> 76</span>             type: "json_string",
<span class='line'> 77</span>             options: {
<span class='line'> 78</span>                 url: "mydata.json"    // Must be a local URL
<span class='line'> 79</span>             }
<span class='line'> 80</span>         }
<span class='line'> 81</span>     ],
<span class='line'> 82</span>     // etc...
<span class='line'> 83</span> });
<span class='line'> 84</span>  *
<span class='line'> 85</span>  * @param {Object} options          All options for the loader
<span class='line'> 86</span>  * @param {String} options.url          URL of JSON file to load
<span class='line'> 87</span>  * @param {mixed} [options[...]]        Other options (see {@link loaders.remote})
<span class='line'> 88</span>  */</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="NAME">loaders.json</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">loader</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">loaders.remote</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT">    </span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT">    </span><span class="COMM">// set ajax settings for loader</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT">    </span><span class="NAME">loader.opts.dataType</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT">  </span><span class="STRN">'json'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="WHIT">    
<span class='line'> 95</span>     </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">loader</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 97</span> 
<span class='line'> 98</span> </span><span class="COMM">// For backwards compatibility</span><span class="WHIT">
<span class='line'> 99</span> </span><span class="NAME">loaders.json_string</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">loaders.json</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>100</span> 
<span class='line'>101</span> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>102</span> </span></pre></body></html>